<script setup>
import { getHomeOthertab } from '../api/home';
import { ref, onBeforeMount } from 'vue';

// const props = defineProps(['id3','type3']);
// let id = props.id3;
// let type = props.type3;
// console.log("电视=",id,type)

let tvList = ref([]);

let getHomeOthertabFun = () => {
    getHomeOthertab({
        page_type: 'activity',
        page_id: 19071
    }).then(res => {
        // console.log("电视的数据=>",res)
        tvList.value = res.data.data.data.sections
        console.log("tvList=", tvList.value)
    })
}

onBeforeMount(() => {
    getHomeOthertabFun()
})

</script>

<template>
     <van-loading type="spinner" color="#ff6900" v-if="!tvList" vertical/>
    <div class="tv-page" v-else>
        <!-- 第一部分 -->
        <div class="pic01" v-if="tvList[0]">
            <img :src="'https:' + tvList[0].body.items[0].img_url" alt="" srcset="">
        </div>
        <div class="pic02" v-if="tvList[2]">
            <img :src="'https:' + tvList[2].body.items[0].img_url" alt="" srcset="">
        </div>
        <div class="box03" v-if="tvList[4]">
            <div class="box03-product-item" v-for="(item, index) in tvList[4].body.items" :key="index">
                <img :src="'https:' + item.img_url">
                <p class="product_name">{{ item.product_name }}</p>
                <p class="product_brief">{{ item.product_brief }}</p>
                <p class="show_price"> ￥{{ item.show_price }}</p>
                <button>立即购买</button>
            </div>
        </div>
        <div class="pic04" v-if="tvList[6]">
            <img :src="'https:' + tvList[6].body.items[0].img_url" alt="" srcset="">
        </div>
        <div class="pic05" v-if="tvList[8]">
            <img :src="'https:' + tvList[8].body.items[0].img_url" alt="" srcset="">
        </div>
        <div class="pic06" v-if="tvList[10]">
            <img :src="'https:' + tvList[10].body.items[0].img_url" alt="" srcset="">
        </div>
        <div class="box07" v-if="tvList[12]">
            <div class="box07-product-item" v-for="(item, index) in tvList[12].body.items" :key="index">
                <img :src="'https:' + item.img_url">
                <p class="product_name">{{ item.product_name }}</p>
                <p class="product_brief">{{ item.product_brief }}</p>
                <p class="show_price"> ￥{{ item.show_price }}</p>
                <button>立即购买</button>
            </div>
        </div>
        <div class="box08" v-if="tvList[14]">
            <div class="box08-product-item" v-for="(item, index) in tvList[14].body.items" :key="index">
                <img :src="'https:' + item.img_url">
                <p class="product_name">{{ item.product_name }}</p>
                <p class="product_brief">{{ item.product_brief }}</p>
                <p class="show_price"> ￥{{ item.show_price }}</p>
            </div>
        </div>
        <div style="width: 100%;height: 40px;background-color: #f9795b;"></div>

    </div>
</template>

<style lang="scss">
.tv-page {
    width: 100%;
   

    .pic01,
    .pic02,
    .pic04,
    .pic05,
    .pic06 {
        width: 100%;
        height: 69px;

        img {
            width: 100%;
            height: 100%;
        }
    }

    .box03,.box07 {
        width: 100%;
        background-color: #ffae99;
        display: flex;
        justify-content: space-evenly;
        flex-wrap: wrap;

        .box03-product-item,.box07-product-item {
            width: 46%;
            height: 290px;
            margin: 8px 0px;
            background-color: #fff;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 9px;
            border-radius: 5px;
            overflow: hidden;

            img {
                width: 100%;
                height: 176px;
            }

            .product_name,
            .product_brief {
                // width: 90%;
                text-align: center;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 1;
                -webkit-box-orient: vertical;
                line-height: 20px;

            }

            .product_name {
                font-size: 13px;
                font-weight: 800;
                margin-top: 17px;
            }

            .product_brief {
                font-size: 13px;
            }

            .show_price {
                font-size: 15px;
                font-weight: 800;
                color: #f54b4b;
            }

            button {
                width: 91px;
                height: 25px;
                outline: none;
                border: none;
                background-color: #f54b4b;
                color: #fff;
                line-height: 25px;
                border-radius: 3px;
                font-size: 12px;
            }
        }

    }

    .box08 {
        width: 100%;
        display: flex;
        justify-content: space-evenly;
        background-color: #ffae99;

        .box08-product-item {
            width: 30%;
            height: 192px;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #fff;
            border-radius: 3px;
            overflow: hidden;
            margin-bottom: 8px;

            img {
                width: 100%;
                height: 115px;
            }

            .product_name,
            .product_brief {

                text-align: center;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 1;
                -webkit-box-orient: vertical;
                line-height: 20px;

            }

            .product_name {
                font-size: 13px;
                font-weight: 800;
                margin-top: 17px;
            }

            .product_brief {
                font-size: 13px;
            }

            .show_price {
                font-size: 15px;
                font-weight: 800;
                color: #f54b4b;
            }

        }
    }

}</style>